<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const arr1 = ["a", "b", "c"];
      //复制数组
      function copyArr(arr) {
        const newArr = []; //创建新数组
        for (let v of arr) {
          newArr.push(v); // 将值“复制”给新数组
        }
        return newArr; //返回新数组
      }
      const arr2 = copyArr(arr1);
      console.log(arr1, arr2);
      console.log(arr1 === arr2); //false
    </script>
  </body>
</html>
